<?php
/**
 * Classe mère des classes contextswitch
 *
 * @package zfbook
 * @subpackage controller
 */
abstract class Zfbook_Controller_ContextSwitch_Abstract
{
    /**
     * Méthode d'affichage
     */
    const CS_POST = 'getContent';

    /**
     * Méthode d'initialisation
     */
    const CS_INIT = 'initContext';
    
    /**
     * Annule le renderer
     */
    public static function initContext()
    {
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
        $viewRenderer->setNoRender(true);
    }
    
    /**
     * Construit un contexte type pour contextSwitch
     *
     * @param string $callbackClass 
     * @param string $mimeType
     * @return array
     */
    protected static function buildContext($callbackClass, $mimeType)
    {
        $context = array();
        $context['headers'] = array('Content-type' => $mimeType);
        $context['callbacks']['post'] = array($callbackClass, self::CS_POST);
        $context['callbacks']['init'] = array($callbackClass, self::CS_INIT);
        return $context;
    }    
}
